#! user/bin/python
# -*- coding: utf-8 -*-

"""
Created on 2021/8/24 13:39

@File: 使用简单的GUI前端_getfilegui-simple.py
@Author: LT
@Description: Use of this module
"""
import sys, os
from tkinter import *
from tkinter.messagebox import showinfo


def onReturnKey():
    cmdline = (f'python 简单的命令行模式_getfile.py -mode client'
               f' -file {content["File"].get()} -port {content["Port"].get()} -host {content["Server"].get()}')
    os.system(cmdline)
    showinfo(f"in {__file__}", "Download complete")


box = Tk()
labels = ["Server", "Port", "File"]
content = {}
for label in labels:
    row = Frame(box)
    row.pack(fill=X)
    Label(row, text=label, width=6).pack(side=LEFT)
    entry = Entry(row)
    entry.pack(side=RIGHT, expand=YES, fill=X)
    content[label] = entry                                  # 让输入框的内容到content字典中

box.title(f"{__file__}")
box.bind("<Return>", (lambda event: onReturnKey()))
box.mainloop()
